package myhadoop;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Mapper类基本决定了输入和输出的格式。Mapper中的key，value有些是基本类型的包装类，
 */
public class WordCountMap extends Mapper<LongWritable,Text,Text, IntWritable> {

    public void map(LongWritable key, Text value,Context context) throws IOException, InterruptedException {
        String line=value.toString();
        String[] strs =line.split(" ");
        for (String s:strs){
            context.write(new Text(s),new IntWritable(1));
        }
    }

}